<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>登录页面</title>
</head>

<body>
  <h1>用户登录</h1>
  用户名：<input name="userName" type="text" id="userName"><br>
  密码：<input name="password" type="password" id="password"><br>
  <input type="button" value="登录" onclick="login()">

  <script src="js/jquery.min.js"></script>
  <script>
    function login() {
      $.ajax({
        type: "post",     //请求方式
        url: "/user/login",    //请求路径
        data: {
          username: $("#username").val,  //请求参数
          password: $("passowrd").val
        },
        success: function (result) {  //请求成功后，执行回调函数
          //密码正确
          if (result) {
            location.href = "index.html"; //页面跳转
          } else {
            //密码错误
            alert("密码错误，请确认");
          }
        }
      });
    }

  </script>
</body>

</html>